package org.vestbjergbyggecenter.TUI;

import java.util.Scanner;

import org.vestbjergbyggecenter.Controller.EmployeeCtr;
	/**
 * @author Khan
 *
 */
public class EmployeeMenu 
{
	private EmployeeCtr employeeCtr;
	private static EmployeeMenu instance = null;
	
	//constructor
	private EmployeeMenu()
    {
        employeeCtr = EmployeeCtr.getInstance();
        start();
    }
	
	//instance generation
	public static EmployeeMenu getInstance()
    {
        if(instance == null)
        {
            instance = new EmployeeMenu();
        }
        return instance;
    }
	
	// start menu
    public void start()
    {
        boolean exit = false;
        while(!exit)
        {
            int choice = printEmployeeMenu();
            switch (choice)
            {
                case 1: listAllEmployees();
                        break;
                case 2: registerSalesAssistant();
                        break;
                case 3: registerManager();
                        break;
                case 4: readEmployeeData();
                        break;
                case 5: readNorm();
                        break;
                case 6: readType();
                        break;
                case 7: updateManager();
                		break;
                case 8: updateSalesAssistant();
                		break;
                case 9: deleteEmployee();
                		break;
                case 10: goBack();
                		break;
            }
      }
    }
        
        //print menu
        public int printEmployeeMenu()
	    {
	        Scanner keyboard = new Scanner(System.in);
	        //System.out.print('\f');
	        System.out.println("***Employee Menu***");
	        System.out.println("1. List all employees");
	        System.out.println("2. Register new sales assistant");
	        System.out.println("3. Register new manager");
	        System.out.println("4. Read employee data ");
	        System.out.println("5. See sales assistant norm");;
	        System.out.println("6. See employee type");
	        System.out.println("7. Update manager");
	        System.out.println("8. Update sales assistant");
	        System.out.println("9. Delete employee");
	        System.out.println("10. Go back");
	        System.out.println("Choice #: ");
	        
	        int choice = keyboard.nextInt();
	        return choice;
	   }
      
        //1
        //prints all the employees
        public void listAllEmployees()
        {
        	EmployeeCtr.getInstance().printEmployees();
        }
        
        //2
        //register new sales assistant
        public void registerSalesAssistant()
        {
        	Scanner keyboard = new Scanner(System.in); 
        	System.out.println('\f');
        	
        	System.out.println("Input sales assistant ID: ");
        	int employeeId=Integer.parseInt(keyboard.nextLine());
        	
        	System.out.println("Input sales assistant name: ");
        	String employeeName=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant CPR: ");
        	long employeeCPR=Long.parseLong(keyboard.nextLine());
        	
        	System.out.println("Input sales assistant address: ");
        	String employeeAddress=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant postal code: ");
        	long employeePostalCode=Long.parseLong(keyboard.nextLine());
        	
        	System.out.println("Input sales assistant city: ");
        	String employeeCity=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant phone number: ");
        	String employeePhone=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant username: ");
        	String employeeUsername=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant password: ");
        	String employeePassword=keyboard.nextLine();
        	
        	System.out.println("Input sales assistant salary: ");
        	int employeeSalary=Integer.parseInt(keyboard.nextLine());       	
        	
        	employeeCtr.createSalesAssistant(employeeId, employeeName, employeeCPR, employeeAddress, employeePostalCode,
        			employeeCity, employeePhone, employeeUsername, employeePassword, employeeSalary);
        }
        
        //3
        //register new manager
        public void registerManager()
        {
        	Scanner keyboard = new Scanner(System.in); 
        	System.out.println('\f');
        	
        	System.out.println("Input manager ID: ");
        	int employeeId=keyboard.nextInt();
        	
        	System.out.println("Input manager name: ");
        	String employeeName=keyboard.nextLine();
        	
        	System.out.println("Input manager CPR: ");
        	long employeeCPR=keyboard.nextLong();
        	
        	System.out.println("Input manager address: ");
        	String employeeAddress=keyboard.nextLine();
        	
        	System.out.println("Input manager postal code: ");
        	long employeePostalCode=keyboard.nextLong();
        	
        	System.out.println("Input manager city: ");
        	String employeeCity=keyboard.nextLine();
        	
        	System.out.println("Input manager phone number: ");
        	String employeePhone=keyboard.nextLine();
        	
        	System.out.println("Input manager username: ");
        	String employeeUsername=keyboard.nextLine();
        	
        	System.out.println("Input manager password: ");
        	String employeePassword=keyboard.nextLine();
        	
        	System.out.println("Input manager salary: ");
        	int employeeSalary=keyboard.nextInt();     
        	
        	System.out.println("Input manager department: ");
        	String department=keyboard.nextLine();
        	
        	employeeCtr.createManager(employeeId, employeeName, employeeCPR, employeeAddress, employeePostalCode, 
        			employeeCity, employeePhone, employeeUsername, employeePassword, employeeSalary, department);
        }
        
        //4
        //read employee data
        public void readEmployeeData()
        {
        	Scanner keyboard = new Scanner(System.in); 
	        System.out.print('\f');
	        System.out.println("Input employee id: ");
	        int id = Integer.parseInt(keyboard.nextLine());	   
	        employeeCtr.printEmployee(id);
        }
        
        //5
        //see norm of sales assistant
        public void readNorm()
        {
        	Scanner keyboard = new Scanner(System.in); 
	        System.out.print('\f');
	        System.out.println("Input sales assistant id: ");
	        int id = Integer.parseInt(keyboard.nextLine());	 
	        
	        employeeCtr.seeSalesAssistantNorm(id);
        }
        
        //6
        //see type of employee
        public void readType()
        {
        	Scanner keyboard = new Scanner(System.in); 
	        System.out.print('\f');
	        System.out.println("Input employee id: ");
	        
	        int id = Integer.parseInt(keyboard.nextLine());	  
	        employeeCtr.checkEmployeeCategory(id);
        }
        
        //7
        //update manager
        public void updateManager()
        {
        	Scanner keyboard = new Scanner(System.in); 
        	System.out.println('\f');
        	
        	System.out.println("Input manager ID: ");
        	int employeeId=keyboard.nextInt();
        	
        	System.out.println("Input manager name: ");
        	String employeeName=keyboard.nextLine();
        	
        	System.out.println("Input manager CPR: ");
        	long employeeCPR=keyboard.nextLong();
        	
        	System.out.println("Input manager address: ");
        	String employeeAddress=keyboard.nextLine();
        	
        	System.out.println("Input manager postal code: ");
        	long employeePostalCode=keyboard.nextLong();
        	
        	System.out.println("Input manager city: ");
        	String employeeCity=keyboard.nextLine();
        	
        	System.out.println("Input manager phone number: ");
        	String employeePhone=keyboard.nextLine();
        	
        	System.out.println("Input manager username: ");
        	String employeeUsername=keyboard.nextLine();
        	
        	System.out.println("Input manager password: ");
        	String employeePassword=keyboard.nextLine();
        	
        	System.out.println("Input manager salary: ");
        	int employeeSalary=keyboard.nextInt();     
        	
        	System.out.println("Input manager department: ");
        	String department=keyboard.nextLine();     
        	
        	employeeCtr.updateManager(employeeId, employeeName, employeeCPR, employeeAddress, employeePostalCode,
        			employeeCity, employeePhone, employeeUsername, employeePassword, employeeSalary, department);
        }
        
        //8
        //update sales assistant
        public void updateSalesAssistant()
        {
        	Scanner keyboard = new Scanner(System.in); 
        	System.out.println('\f');
        	
        	System.out.println("Input manager ID: ");
        	int employeeId=keyboard.nextInt();
        	
        	System.out.println("Input manager name: ");
        	String employeeName=keyboard.nextLine();
        	
        	System.out.println("Input manager CPR: ");
        	long employeeCPR=keyboard.nextLong();
        	
        	System.out.println("Input manager address: ");
        	String employeeAddress=keyboard.nextLine();
        	
        	System.out.println("Input manager postal code: ");
        	long employeePostalCode=keyboard.nextLong();
        	
        	System.out.println("Input manager city: ");
        	String employeeCity=keyboard.nextLine();
        	
        	System.out.println("Input manager phone number: ");
        	String employeePhone=keyboard.nextLine();
        	
        	System.out.println("Input manager username: ");
        	String employeeUsername=keyboard.nextLine();
        	
        	System.out.println("Input manager password: ");
        	String employeePassword=keyboard.nextLine();
        	
        	System.out.println("Input manager salary: ");
        	int employeeSalary=keyboard.nextInt();        
	        
	        
	        employeeCtr.updateSalesAssistant(employeeId, employeeName, employeeCPR, employeeAddress, 
	        		employeePostalCode, employeeCity, employeePhone, employeeUsername, employeePassword, employeeSalary);
	    }
        
        //9
        //delete employee
        public void deleteEmployee()
        {
        	Scanner keyboard = new Scanner(System.in); 
	        System.out.print('\f');
	        System.out.println("Input employee id: ");
	        int id = Integer.parseInt(keyboard.nextLine());	
	        
	        employeeCtr.deleteEmployee(id);
        }
        
        // calls and returns to main menu
		public void goBack()
		{
			MainMenu.getInstance().start();
		}

}
